﻿<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="FinalDecisions.aspx.cs"
    Inherits="PPAP.Web.Part.FinalDecisions" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <title></title>
    <script src="../Common/My97DatePicker/WdatePicker.js" type="text/javascript"></script>
    <style type="text/css">
        .td1
        {
            font-weight: bold;
            border-color: #2A48CE;
            border: 0px;

            border-color: Gray;
            margin: 0;
        }
        .td2
        {
            border-color: #2A48CE;
            border: 0px;

            border-color: Gray;
            margin: 0;
            border-top-width: 0;
        }
        .td3
        {
            border-color: #2A48CE;
            border: 0px;

            border-color: Gray;
            margin: 0;
            border-top-width: 0;
            border-left-width: 0;
        }
        .td4
        {
            border-color: #2A48CE;
            border: 0;
            border-bottom-width: 1px;

            border-color: Gray;
        }
        .td5
        {
            border-color: #2A48CE;
            border: 0;
            border-left-width: 1px;

            border-color: Gray;
            text-align: center;
        }
        .td6
        {
            border-color: #2A48CE;
            border: 0;
            border-top-width: 1px;

            border-color: Gray;
            height: 32px;
        }
    </style>
    <script language="javascript" type="text/javascript">
        function del(id) {
            if (id > 0) {
                if (confirm('Please confirm to delete the file.')) {
                    url = "FinalDecisions.aspx?deid=" + id;
                    window.location.href = url;
                }
            }
        }

        function check() {
            var txtReason = document.getElementById("txtReason");
            if (txtReason.value == "") {
                alert("Please input reason for disapproval ");
                txtReason.focus();
                return false;
            }
            return confirm('Are you sure you want to approve?');
        }

        function check2() {
            var txtReason = document.getElementById("txtReason");
            if (txtReason.value == "") {
                alert("Please input reason for disapproval ");
                txtReason.focus();
                return false;
            }
            return confirm('Are you sure you want to reject?');
        }

        function check3() {  //Submit
            var rbtG1 = document.getElementById("rbtG1");
            var rbtY1 = document.getElementById("rbtY1");
            var rbtR1 = document.getElementById("rbtR1");
            var txtPartRelatedReason = document.getElementById("txtPartRelatedReason");
            var rbtG2 = document.getElementById("rbtG2");
            var rbtY2 = document.getElementById("rbtY2");
            var rbtR2 = document.getElementById("rbtR2");
            var txtProcessRelatedReason = document.getElementById("txtProcessRelatedReason");
            var rbtG3 = document.getElementById("rbtG3");
            var rbtY3 = document.getElementById("rbtY3");
            var rbtR3 = document.getElementById("rbtR3");
            var txtFinalResultReason = document.getElementById("txtFinalResultReason");
            if (!rbtG1.checked && txtPartRelatedReason.value=="") {
                alert("Please input reason (Part related result)  ");
                txtPartRelatedReason.focus();
                return false;
            }
            if (!rbtG2.checked && txtProcessRelatedReason.value == "") {
                alert("Please input reason (Process related result)  ");
                txtProcessRelatedReason.focus();
                return false;
            }
            if (!rbtG3.checked && txtFinalResultReason.value == "") {
                alert("Please input reason (Final result of PPAR)  ");
                txtFinalResultReason.focus();
                return false;
            }
            return confirm('Are you sure you want to submit?');
        }

        function ShowDisplay(obj) {
            if (document.all[obj].style.display == "") {
                document.all[obj].style.display = "none";
            }
            else {
                document.all[obj].style.display = "";
            }
        }
    </script>
</head>
<body style="font-family: Arial, Helvetica, sans-serif;">
    <form id="form1" runat="server">
    <div>
    <fieldset><legend><strong><a onclick="javascript:ShowDisplay('GridView3');" href="#">Inspection result(display/hide)</a></strong></legend>
    <asp:GridView ID="GridView3" style="display: none" runat="server" CellPadding="4" Width="70%" ForeColor="#333333"
                        GridLines="None" AutoGenerateColumns="False">
                        <AlternatingRowStyle BackColor="White" />
                        <Columns>
                            <asp:TemplateField HeaderText="Department" HeaderStyle-Font-Size="12px" ItemStyle-HorizontalAlign="Center">
                                <ItemTemplate>
                                    <asp:Label ID="Label3" runat="server" Text='<%#Eval("testitemname") %>'></asp:Label>
                                </ItemTemplate>
                                <ItemStyle HorizontalAlign="Center"></ItemStyle>
                            </asp:TemplateField>
                            <asp:TemplateField HeaderText="status" HeaderStyle-Font-Size="12px" ItemStyle-HorizontalAlign="Center">
                                <ItemTemplate>
                                   <asp:Label ID="Label5" runat="server" Text='<%#Status(Eval("STATUS").ToString()) %>'></asp:Label>
                                </ItemTemplate>
                                <ItemStyle HorizontalAlign="Center"></ItemStyle>
                            </asp:TemplateField>
                            <asp:TemplateField HeaderText="result" HeaderStyle-Font-Size="12px" ItemStyle-HorizontalAlign="Center">
                                <ItemTemplate>
                                    <asp:Image ID="Image1" Visible='<%#Eval("RESULT").ToString()==""?false:true %>' ImageUrl='<%#"~/Part/image/"+Eval("RESULT")+".png" %>' runat="server" />
                                </ItemTemplate>
                                <ItemStyle HorizontalAlign="Center"></ItemStyle>
                            </asp:TemplateField>
                        </Columns>
                        <EditRowStyle BackColor="#2E8AC5" />
                        <FooterStyle BackColor="#507CD1"  ForeColor="White" />
                        <HeaderStyle BackColor="#E7E8E8"  ForeColor="#000000" />
                        <PagerStyle BackColor="#2461BF" ForeColor="White" HorizontalAlign="Center" />
                        <RowStyle BackColor="#EFF3FB" />
                        <SelectedRowStyle BackColor="#D1DDF1"  ForeColor="#333333" />
                        <SortedAscendingCellStyle BackColor="#F5F7FB" />
                        <SortedAscendingHeaderStyle BackColor="#6D95E1" />
                        <SortedDescendingCellStyle BackColor="#E9EBEF" />
                        <SortedDescendingHeaderStyle BackColor="#4870BE" />
                    </asp:GridView>
        </fieldset>
        <asp:Repeater ID="Repeater1" runat="server" Visible="False">
            <HeaderTemplate>
                <table width="260px;" cellspacing="0">
                    <tr bgcolor="#F2F2F2">
                        <td colspan="3" class="td1">
                            Inspection result
                        </td>
                    </tr>
                    <tr bgcolor="#F2F2F2">
                        <td class="td2">
                            Department
                        </td>
                        <td class="td3">
                            status
                        </td>
                        <td class="td3">
                            Result
                        </td>
                    </tr>
            </HeaderTemplate>
            <ItemTemplate>
                <tr>
                    <td class="td2">
                        <%# DataBinder.Eval(Container.DataItem, "testitemname")%>
                    </td>
                    <td class="td3">
                        <%#Status(Eval("STATUS").ToString()) %>
                    </td>
                    <td class="td3">
                        <%# DataBinder.Eval(Container.DataItem, "result").ToString() == "" ? "&nbsp;" : DataBinder.Eval(Container.DataItem, "result").ToString() == "G" ? "Green" : DataBinder.Eval(Container.DataItem, "result").ToString()=="R"?"Red":"Yellow"%>
                    </td>
                </tr>
            </ItemTemplate>
            <FooterTemplate>
                </table>
            </FooterTemplate>
        </asp:Repeater>
        <br />
        <table width="100%" cellspacing="0" style="border-color: #2A48CE; border: 0px; border-style: solid;
            border-color: Gray; border-spacing: 0px;">
            <tr bgcolor="#E5E5E6">
                <td class="td4" style="height: 32px; width:20%; font-weight: bold;">
                    Final decisions
                </td>
                <td class="td4" align="center" width="12%">
                    Release(green)
                </td>
                <td class="td4" align="center" width="18%">
                    Conditional release(yellow)
                </td>
                <td class="td4" align="center" width="12%">
                    Rejected(red)
                </td>
                <td class="td4" style="width:38%; " align="center">
                    reason
                </td>
            </tr>
            <tr>
                <td style="font-weight: bold; color: #2E8AC5; height: 25px;">
                    Part related result
                </td>
                <td class="td5">
                    <asp:RadioButton ID="rbtG1" runat="server" Checked="True" GroupName="a" />
                </td>
                <td class="td5">
                    <asp:RadioButton ID="rbtY1" runat="server" GroupName="a" />
                </td>
                <td class="td5">
                    <asp:RadioButton ID="rbtR1" runat="server" GroupName="a" />
                </td>
                <td class="td5">
                    <asp:TextBox ID="txtPartRelatedReason" runat="server" Width="300px"></asp:TextBox>
                </td>
            </tr>
            <tr>
                <td style="font-weight: bold; color: #2E8AC5; height: 25px;">
                    Process related result
                </td>
                <td class="td5">
                    <asp:RadioButton ID="rbtG2" runat="server" Checked="True" GroupName="b" />
                </td>
                <td class="td5">
                    <asp:RadioButton ID="rbtY2" runat="server" GroupName="b" />
                </td>
                <td class="td5">
                    <asp:RadioButton ID="rbtR2" runat="server" GroupName="b" />
                </td>
                <td class="td5">
                    <asp:TextBox ID="txtProcessRelatedReason" runat="server" Width="300px"></asp:TextBox>
                </td>
            </tr>
            <tr>
                <td style="font-weight: bold; color: #2E8AC5; height: 25px;">
                    Final result of PPAR
                </td>
                <td class="td5">
                    <asp:RadioButton ID="rbtG3" runat="server" Checked="True" GroupName="c" 
                        AutoPostBack="True" oncheckedchanged="rbtG3_CheckedChanged" />
                </td>
                <td class="td5">
                    <asp:RadioButton ID="rbtY3" runat="server" GroupName="c" AutoPostBack="True" 
                        oncheckedchanged="rbtG3_CheckedChanged" />
                </td>
                <td class="td5">
                    <asp:RadioButton ID="rbtR3" runat="server" GroupName="c" AutoPostBack="True" 
                        oncheckedchanged="rbtG3_CheckedChanged" />
                </td>
                <td class="td5">
                    <asp:TextBox ID="txtFinalResultReason" runat="server" Width="300px"></asp:TextBox>
                </td>
            </tr>
            <tr runat='server' id="trdate1">
                <td colspan="5" class="td6" id="td_resub" runat="server">
                    re-submission date:<asp:TextBox ID="txtSubmissionDate" onclick="WdatePicker();" runat="server"></asp:TextBox>
                </td>
            </tr>
        </table>
        <hr />
        <table width="100%" style="border-color: #2A48CE; border: 0px; border-style: solid;
            border-color: Gray; border-spacing: 0px;">
           
            <tr>
                <td style="font-weight: bold;">
                    Upload deviation sheet：

                </td>
                <td align="right">
                    <asp:Label ID="lblUp" runat="server" Visible="False"></asp:Label>
                </td>
            </tr>
            <tr>
                <td colspan="2">
                    <asp:GridView ID="GridView1" runat="server" CellPadding="4" Width="100%" ForeColor="#333333"
                        GridLines="None" AutoGenerateColumns="False">
                        <AlternatingRowStyle BackColor="White" />
                        <Columns>
                            <asp:TemplateField HeaderText="No." ItemStyle-HorizontalAlign="Center">
                                <ItemTemplate>
                                    <asp:Label ID="Label1" runat="server" Text='<%# Eval("rownum") %>'></asp:Label>
                                </ItemTemplate>
                                <ItemStyle HorizontalAlign="Center"></ItemStyle>
                            </asp:TemplateField>
                            <asp:TemplateField HeaderText="File name" ItemStyle-HorizontalAlign="Center">
                                <ItemTemplate>
                                    <a href='<%# GetLink(Eval("F_URL").ToString()) %>' style="display: none;" target="_blank">
                                        <span style="color: Blue;">
                                            <%# Eval("F_Filename")%></span></a>
                                    <asp:LinkButton ID="LinkButton3" Visible="true" Text='<%# Eval("F_URL") %>' runat="server"
                                        OnClick="LinkButton2_Click"><%# Eval("F_Filename")%></asp:LinkButton>
                                </ItemTemplate>
                                <ItemStyle HorizontalAlign="Center"></ItemStyle>
                            </asp:TemplateField>
                            <asp:TemplateField HeaderText="Size" ItemStyle-HorizontalAlign="Center">
                                <ItemTemplate>
                                    <asp:Label ID="Label7" runat="server" Text='<%# Eval("filesize") %>'></asp:Label>
                                </ItemTemplate>
                                <ItemStyle HorizontalAlign="Center"></ItemStyle>
                            </asp:TemplateField>
                            <asp:TemplateField HeaderText="Create date" ItemStyle-HorizontalAlign="Center">
                                <ItemTemplate>
                                    <asp:Label ID="Label8" runat="server" Text='<%#Eval("UpTime").ToString()==""?"":DateTime.Parse(Eval("UpTime").ToString()).ToString("yyyy-MM-dd")  %>'></asp:Label>
                                </ItemTemplate>
                                <ItemStyle HorizontalAlign="Center"></ItemStyle>
                            </asp:TemplateField>
                            <asp:TemplateField HeaderText="Create by" HeaderStyle-Font-Size="12px"  ItemStyle-HorizontalAlign="Center" ItemStyle-Width="15%">
                                <ItemTemplate>
                                    <asp:Label ID="Label4" runat="server" Text='<%# Eval("UpBy") %>'></asp:Label>
                                </ItemTemplate>
                                <ItemStyle HorizontalAlign="Center"></ItemStyle>
                            </asp:TemplateField>
                            <asp:TemplateField HeaderText="Delete" ItemStyle-HorizontalAlign="Center">
                                <ItemTemplate>
                                    <asp:LinkButton ID="LinkButton1" Visible='<%#Eval("F_ID").ToString()==""?false:false %>'
                                        runat="server" OnClientClick="return confirm('Please confirm to delete the file.')"
                                        PostBackUrl='<%# "FinalDecisions.aspx?deid="+Eval("F_ID")%>'>Delete</asp:LinkButton>
                                    <img src="../Images/newimg/delete.png" title="Delete" onclick="<%#"javascript:del("+Eval("F_ID")+")" %>" />
                                </ItemTemplate>
                            </asp:TemplateField>
                        </Columns>
                        <EditRowStyle BackColor="#2E8AC5" />
                        <FooterStyle BackColor="#507CD1" Font-Bold="True" ForeColor="White" />
                        <HeaderStyle BackColor="#E7E8E8" Font-Bold="True" ForeColor="#000000" />
                        <PagerStyle BackColor="#2461BF" ForeColor="White" HorizontalAlign="Center" />
                        <RowStyle BackColor="#EFF3FB" />
                        <SelectedRowStyle BackColor="#D1DDF1" Font-Bold="True" ForeColor="#333333" />
                        <SortedAscendingCellStyle BackColor="#F5F7FB" />
                        <SortedAscendingHeaderStyle BackColor="#6D95E1" />
                        <SortedDescendingCellStyle BackColor="#E9EBEF" />
                        <SortedDescendingHeaderStyle BackColor="#4870BE" />
                    </asp:GridView>
                </td>
            </tr>
             <tr runat="server" id="trdate2">
                <td colspan="2">
                    Valid until(expire date):<asp:TextBox ID="txtValidUntil" onclick="WdatePicker();"
                        runat="server"></asp:TextBox>
                </td>
            </tr>
        </table>
        <hr />
        <table width="100%">
            <tr>
                <td colspan="2">
                 <asp:Label ID="lblTask" runat="server" Text="Approval process:" Font-Bold="True" 
                        Visible="False"></asp:Label>
                    <asp:GridView ID="GridView2" runat="server" CellPadding="4" Width="100%" ForeColor="#333333"
                        GridLines="None" AutoGenerateColumns="False" Visible="False">
                        <AlternatingRowStyle BackColor="White" />
                        <Columns>
                            <asp:TemplateField HeaderText="No." ItemStyle-HorizontalAlign="Center">
                                <ItemTemplate>
                                    <asp:Label ID="Label10" runat="server" Text='<%# Eval("rownum") %>'></asp:Label>
                                </ItemTemplate>
                                <ItemStyle HorizontalAlign="Center"></ItemStyle>
                            </asp:TemplateField>
                            <asp:TemplateField HeaderText="Remark" ItemStyle-HorizontalAlign="Center">
                                <ItemTemplate>
                                    <asp:Label ID="Label11" runat="server" Text='<%#Eval("REAMRK") %>'></asp:Label>
                                </ItemTemplate>
                                <ItemStyle HorizontalAlign="Center"></ItemStyle>
                            </asp:TemplateField>
                            <asp:TemplateField HeaderText="User" ItemStyle-HorizontalAlign="Center">
                                <ItemTemplate>
                                    <asp:Label ID="Label12" runat="server" Text='<%#Eval("CREATEUSER") %>'></asp:Label>
                                </ItemTemplate>
                                <ItemStyle HorizontalAlign="Center"></ItemStyle>
                            </asp:TemplateField>
                            <asp:TemplateField HeaderText="Time" ItemStyle-HorizontalAlign="Center">
                                <ItemTemplate>
                                    <asp:Label ID="Label13" runat="server" Text='<%# Eval("CREATETIME") %>'></asp:Label>
                                </ItemTemplate>
                                <ItemStyle HorizontalAlign="Center"></ItemStyle>
                            </asp:TemplateField>
                            
                        </Columns>
                        <EditRowStyle BackColor="#2E8AC5" />
                        <FooterStyle BackColor="#507CD1" Font-Bold="True" ForeColor="White" />
                        <HeaderStyle BackColor="#E7E8E8" Font-Bold="True" ForeColor="#000000" />
                        <PagerStyle BackColor="#2461BF" ForeColor="White" HorizontalAlign="Center" />
                        <RowStyle BackColor="#EFF3FB" />
                        <SelectedRowStyle BackColor="#D1DDF1" Font-Bold="True" ForeColor="#333333" />
                        <SortedAscendingCellStyle BackColor="#F5F7FB" />
                        <SortedAscendingHeaderStyle BackColor="#6D95E1" />
                        <SortedDescendingCellStyle BackColor="#E9EBEF" />
                        <SortedDescendingHeaderStyle BackColor="#4870BE" />
                    </asp:GridView>
                    <br />
                    <asp:Label ID="Label9" runat="server" Text="Reason:" Font-Bold="True"></asp:Label>
                    <asp:TextBox ID="txtReason" runat="server" Height="50px" TextMode="MultiLine" Width="100%"></asp:TextBox>
                </td>
            </tr>
             <tr>
                <td colspan="2" align="center">
                    <asp:Button ID="btnSave" runat="server" CssClass="button" 
                        onclick="btnSave_Click" Text="Save"  />
&nbsp;
                    <asp:Button ID="btnSubmit" runat="server" CssClass="button" OnClick="btnSubmit_Click"
                        OnClientClick="return check3()" Text="Submit"
                        Visible="False" />
                    <br />
                   
                </td>
            </tr>
            <tr>
                <td colspan="2" align="right">
                    <asp:Button ID="btnApprove" runat="server" CssClass="button" Text="Approve" OnClick="btnApprove_Click"
                        OnClientClick="return confirm('Are you sure you want to approve?');" 
                        Visible="False" />
                    &nbsp;&nbsp;&nbsp;&nbsp;
                    <asp:Button ID="btnReject" runat="server" CssClass="button" Text="Reject" OnClick="btnReject_Click"
                        OnClientClick="return check2();" Visible="False" />
                    <asp:Button ID="btnApprove2" runat="server" CssClass="button" Text="Approve" OnClientClick="return confirm('Are you sure you want to approve?');"
                        Visible="False" OnClick="btnApprove2_Click" />
                    &nbsp;&nbsp;&nbsp;&nbsp;
                    <asp:Button ID="btnReject2" runat="server" CssClass="button" Text="Reject" OnClientClick="return check2();"
                        Visible="False" OnClick="btnReject2_Click" />
                </td>
            </tr>
            <tr>
                <td colspan="2" align="right">
                    &nbsp;&nbsp;&nbsp;&nbsp;
                    </td>
            </tr>
        </table>
    </div>
    </form>
</body>
</html>
